import re

from django.db import models


# Create your models here.

class Student(models.Model):
    sno = models.CharField(max_length=100, primary_key=True, verbose_name="sno")
    name = models.CharField(max_length=100, verbose_name="name")
    sex = models.IntegerField(verbose_name="sex")
    college = models.IntegerField(verbose_name="college")
    major = models.CharField(max_length=100, verbose_name="major")
    phone = models.CharField(max_length=100, verbose_name="phone")
    email = models.CharField(max_length=100, verbose_name="email")
    qq = models.CharField(max_length=100, verbose_name="qq")
    wechat = models.CharField(max_length=100, verbose_name="wechat")

    class Meta:
        db_table = 'Student'
        verbose_name = 'Student'
        verbose_name_plural = verbose_name


class Project(models.Model):
    name = models.CharField(max_length=100, verbose_name="name")
    main_track = models.IntegerField(verbose_name="main_track")
    sub_track1 = models.IntegerField(verbose_name="sub_track1")
    sub_track2 = models.IntegerField(verbose_name="sub_track2")
    year = models.CharField(max_length=100, verbose_name="year")
    college = models.IntegerField(verbose_name="college")
    brief = models.TextField(verbose_name="brief")
    form_url = models.TextField(verbose_name="form_url")
    enclosure_url = models.TextField(verbose_name="enclosure_url")

    class Meta:
        db_table = 'Project'
        verbose_name = 'Project'
        verbose_name_plural = verbose_name


class Teacher(models.Model):
    tno = models.CharField(max_length=100, primary_key=True, verbose_name="tno")
    name = models.CharField(max_length=100, verbose_name="name")
    title = models.CharField(max_length=100, verbose_name="title")
    college = models.IntegerField(verbose_name="college")
    phone = models.CharField(max_length=100, verbose_name="phone")
    email = models.CharField(max_length=100, verbose_name="email")

    class Meta:
        db_table = 'Teacher'
        verbose_name = 'Teacher'
        verbose_name_plural = verbose_name


class ProjectStudent(models.Model):
    pid = models.ForeignKey("Project", on_delete=models.CASCADE)
    sno = models.ForeignKey("Student", on_delete=models.CASCADE)
    index = models.IntegerField(verbose_name="index")
    division = models.CharField(max_length=100, verbose_name="division")

    class Meta:
        db_table = 'ProjectStudent'
        verbose_name = 'ProjectStudent'
        verbose_name_plural = verbose_name


class ProjectTeacher(models.Model):
    pid = models.ForeignKey("Project", on_delete=models.CASCADE)
    tno = models.ForeignKey("Teacher", on_delete=models.CASCADE)
    index = models.IntegerField(verbose_name="index")

    class Meta:
        db_table = 'ProjectTeacher'
        verbose_name = 'ProjectTeacher'
        verbose_name_plural = verbose_name
